{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "db3f6090-4fcc-4efc-9b6f-c1af35510bab",
   "metadata": {},
   "outputs": [],
   "source": [
    "class ReferenceFrame:\n",
    "    def __init__(self, velocity=0):\n",
    "        self.v = velocity  # 速度，以光速 c 为单位（无量纲）\n",
    "        self.beta = v #光速c为单位，所以是一致的（本来是v/c）\n",
    "        self._velocity_init(velocity)\n",
    "\n",
    "\n",
    "    def _velocity_init(self,v):\n",
    "    #根据速度直接算出其他的量\n",
    "        if abs(self.v) >= 1: # 参考系还是不要直接到光速的好，不然无限了\n",
    "            raise ValueError(\"速度绝对值必须小于光速 (|v| < 1)\")\n",
    "            self.gamma = infinity\n",
    "            self.rapidity = infinity if self.v > 0 else -infinity\n",
    "        else:\n",
    "            self.gamma = 1 / sqrt(1 - self.v**2) # 洛伦兹因子\n",
    "            self.rapidity = arctanh(self.v)\n",
    "\n",
    "    def lorentz_transform(self, t, x, other):\n",
    "        \"\"\"将事件 (t, x) 从当前参考系变换到另一参考系，返回 (t', x')\"\"\"\n",
    "        u = self.relative_velocity(other)\n",
    "        gamma = 1 / sqrt(1 - u**2) if u != 1 else infinity\n",
    "        t_prime = gamma * (t - u * x)\n",
    "        x_prime = gamma * (x - u * t)\n",
    "        return (t_prime, x_prime)\n",
    "\n",
    "    \"\"\"\n",
    "    后面deepseek给出的程序基本是是一种相对的\n",
    "    不过新的编程方法……可以先把这些转为一种“绝对的存在”，然后再送回需要的坐标系吧？\n",
    "    比方说，一个0.6光速运动的粒子发出一个相对于自己0.8速的电子……要怎么整\n",
    "    返回一个v……以及进入一个v？\n",
    "    多一个0的话，“绝对参考系”自己确实也可以有了\n",
    "    而一般的则可以ref0这样直接与绝对做\n",
    "    S1里的速度1，进入S2中看？但是类的对象……不能直接传递吧？\n",
    "    或者是v，这个系看？——init可以先出绝对的实际值？\n",
    "    \"\"\"\n",
    "\n",
    "    def generate_length(proper_length):\n",
    "        #沿着运动方向的长度，而垂直方向的暂时没考虑\n",
    "        return proper_length / self.gamma\n",
    "        \n",
    "    def generate_time(proper_time):\n",
    "        return proper_time * self.gamma\n",
    "\n",
    "    def generate_velocity(proper_velocity): #在这个系里的一个速度，转换到绝对坐标系里是啥样\n",
    "        velocity_s0 = (self.v + velocity)/()\n",
    "\n",
    "\n",
    "    "
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "SageMath 10.5",
   "language": "sage",
   "name": "sagemath"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
